﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Admx_Generator
{
    public partial class frmChooseCategory : Form
    {
        internal frmChooseCategory(Category[] categories)
        {
            InitializeComponent();
            this.lstCategories.Items.AddRange(categories);
        }

        #region (internal properties)

        /// <summary>
        /// Return the Category that the user have selected or null if the user haven't select any.
        /// </summary>
        internal Category SelectedCategory
        {
            get
            {
                if (this.lstCategories.SelectedIndex != -1 && this.lstCategories.SelectedItem != null)
                    return (Category)this.lstCategories.SelectedItem;
                return null;
            }
        }

        #endregion (internal properties)

        #region (UI Managment)

        private void btnOk_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }

        private void lstCategories_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.btnOk.Enabled = this.lstCategories.SelectedIndex != -1;
        }

        #endregion (UI Managment)
    }
}
